<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class New_user extends CI_Controller {

    public function index() {        
        if (!$this->input->post())
        {
            $this->load->view('master');
            return TRUE;
        }

        $this->load->model('user_model', '', TRUE);
        
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('master');
            return FALSE;
        }

        if ($error = $this->user_model->add_new_user($this->input->post()))
        {
            $this->session->set_flashdata('error', '<div class="error">There was an error submitting the form.</div>');
            redirect('new_user');
        }

        redirect('/');
    }
}